package com.zzh.bc.db.converter;

import com.zzh.bc.db.ColumnDbType;

import java.sql.ResultSet;
import java.sql.SQLException;

/**
 *
 * @Date: 2021/5/24 13:39
 * @Email: zzh_hz@126.com
 * @QQ: 1299234582
 * @Author: zzh
 * @Description: 布尔值
 */
public class BooleanColumnConverter implements ColumnConverter<Boolean> {
    @Override
    public Boolean getFieldValue(ResultSet cursor, int index) throws SQLException {
        return cursor.getBoolean(index);
    }

    @Override
    public Object fieldValue2DbValue(Boolean fieldValue) {
        if (fieldValue == null) {
            return null;
        }
        return fieldValue ? 1 : 0;
    }

    @Override
    public ColumnDbType getColumnDbType() {
        return ColumnDbType.INTEGER;
    }
}
